<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../../css/mui.min.css" rel="stylesheet" />
	</head>
	<style>
		.oa-contact-avatar {
			width: 75px;
		}
		
		.oa-contact-name,
		oa-contact-position {
			float: left;
		}
		
		img {
			width: 55%;
		}
		
		p {
			text-indent: 22px;
		}
		
		.mui-popover {
			height: 300px;
		}
		
		.mui-content {
			padding: 10px;
		}
		
		p {
			text-indent: 22px;
		}
		
		span.mui-icon {
			font-size: 14px;
			color: #007aff;
			margin-left: -15px;
			padding-right: 10px;
		}
		
		#info {
			padding: 20px 10px;
		}
	</style>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-back  mui-icon-backmui-pull-left"></a>
			<h1 class="mui-title">编辑资料</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group">
				<div class="mui-input-row mui-hidden" id="uploadImg">
					<label>上传头像</label>
					<a class="mui-navigate-right" href="#picture"></a>
				</div>
				<div class="mui-input-row">
					<label>公司名称</label>
					<input id="companyName" type="text" class="mui-input-clear" placeholder="输入公司名称">
				</div>
				<div class="mui-input-row">
					<label>公司地址</label>
					<input id="companyAddress" type="text" class="mui-input-clear" placeholder="输入公司地址">
				</div>
				<div class="mui-input-row">
					<label>联系人姓名</label>
					<input id="contactName" type="text" class="mui-input-clear" placeholder="输入联系人姓名">
				</div>
				<div class="mui-input-row">
					<label>联系人电话</label>
					<input id="contactPhone" type="text" class="mui-input-clear" placeholder="输入联系电话">
				</div>
				<div class="mui-input-row">
					<label>QQ号码</label>
					<input id="qq" type="text" class="mui-input-clear" placeholder="输入QQ联系方式">
				</div>

				<div class="mui-input-row">
					<label>微信号码</label>
					<input id="wechat" type="text" class="mui-input-clear" placeholder="输入微信联系方式">
				</div>

				<div class="mui-input-row">
					<label>邮件地址</label>
					<input id="email" type="email" class="mui-input-clear" placeholder="输入邮件联系方式">
				</div>
			</form>
		</div>
		<nav class="mui-bar mui-bar-tab">
			<a id="enterClear" class="mui-tab-item" href="#">
				取消
			</a>
			<a class="mui-tab-item" href="#">
			</a>
			<a class="mui-tab-item" href="#">
			</a>
			<a id="enterEdit" class="mui-tab-item" href="#">
				提交
			</a>
		</nav>

		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/myjs/localVarchar.js"></script>
		<script src="../../../js/ipjs/ip.js"></script>
		<script src="../../../js/constatnt/var.js"></script>
		<script type="text/javascript">
			var buttons = ["paizhao", "photo", "suiji", "clear", "enterTijiao"];
			mui.init();
			document.getElementById("uploadImg").addEventListener('tap', function() {})
			var info = document.getElementById("info");
			mui('body').on('tap', '.mui-popover-action li>a', function() {
				var a = this,
					parent;
				for(parent = a.parentNode; parent != document.body; parent = parent.parentNode) {
					if(parent.classList.contains('mui-popover-action')) {
						break;
					}
				}
			});
			document.getElementById("email").addEventListener("blur", function() {
				if(!checkEmail(document.getElementById("email").value)) {
					mui.toast("邮箱格式错误");
				}
			});
			document.getElementById("enterClear").addEventListener('tap', function() {
				mui("input").each(function() {
					this.value = "";
				});
			});

			document.getElementById("enterEdit").addEventListener('tap', function() {
				var userInfo = {
					companyName: document.getElementById("companyName").value,
					companyAddress: document.getElementById("companyAddress").value,
					contactName: document.getElementById("contactName").value,
					contactPhone: document.getElementById("contactPhone").value,
					qq: document.getElementById("qq").value,
					wechat: document.getElementById("wechat").value,
					email: document.getElementById("email").value,
					phone: localStorage.getItem(LOCAL_USER_INFO)
				};
				if(userInfo.companyName != "" ||
					userInfo.companyAddress != "" ||
					userInfo.contactName != "" ||
					userInfo.contactPhone != "" ||
					userInfo.qq != "" ||
					userInfo.wechat != "" ||
					userInfo.email != "") {
					mui.ajax(ip + '/userInfo/editUserInfo', {
						data: JSON.stringify(userInfo),
						dataType: 'json', //服务器返回json格式数据
						type: 'post', //HTTP请求类型
						timeout: 10000, //超时时间设置为10秒；
						headers: {
							'Content-Type': 'application/json'
						},
						success: function(data) {
							var status = data.data.code;
							alert(data.data.object);
							if(status == OPERATION_SUCCESS) {

							} else if(status == OPERATION_FAIL) {

							}
						},
						error: function(xhr, type, errorThrown) {
							//异常处理；
							mui.toast("系统异常！");
						}
					});
				} else {
					alert("您未填信息");
				}

			});

			function checkEmail(myemail) {　　　
				var myReg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
				if(myReg.test(myemail)) {　　　　
					return true;　　
				} else {　　　　
					return false;
				}
			}

			function setHtml(e) {
				var img = document.createElement("img");
				img.setAttribute("src", e);
				document.body.appendChild(img);
			}
			// 拍照获取图片
			function getImage() {
				var c = plus.camera.getCamera();
				c.captureImage(function(e) {
					plus.io.resolveLocalFileSystemURL(e, function(entry) {
						var path = entry.toLocalURL();
						document.getElementById("headimg").src = path;
						//就是这里www.bcty365.com 
					}, function(e) {
						mui.toast("读取拍照文件错误：" + e.message);
					});
				})
			};

			// 从相册中选择图片 
			function galleryImg() {
				// 从相册中选择图片
				plus.gallery.pick(function(e) {
					for(var i in e.files) {
						var fileSrc = e.files[i]
						setHtml(fileSrc);
					}
				}, function(e) {
					console.log("取消选择图片");
				}, {
					filter: "image",
					multiple: true,
					maximum: 1,
					system: false,
					onmaxed: function() {
						plus.nativeUI.alert('最多只能选择1张图片');
					}
				});
			}
			// 上传的方法
			function upload() {
				var files = document.getElementById('testImg')
				MicroTaskGUID = common.guid();

				var rul = "服务器地址"

				var imgsArr = mui(".task-img");

				mui.each(imgsArr, function(index, item) {
					// 		console.log(index)
					// 		console.log(item.src)
					createUp(item)
				})

				function createUp(files) {
					var task = plus.uploader.createUpload(url, {
							method: "POST"
						},
						function(t, status) { //上传完成
							if(status == 200) {
								console.log("上传成功：" + t.responseText);
							} else {
								console.log("上传失败：" + status);
							}
						}
					);
					//添加其他参数
					//	    task.addData("name","test");
					task.addFile(files.src, {
						key: files.src
					});
					task.start();
				}
			}
		</script>
	</body>

</html>